 <template>
    <div class="prdtDetail-wrapper">
        <!-- <searchPrdt/> -->
     <!--   <Banner/>-->

      <div class="homeBanner-wrapper">
            <el-carousel height="3.14rem">
                <el-carousel-item v-for="(item, index) in thumbs" :key="index">
                    <a :href="item.href">
                        <img :src="constant.api_url + item" >
                    </a>
                </el-carousel-item>
            </el-carousel>
        </div>

        <div class="detailInfo-box">
            <div class="item-box">
                <div class="bottom-info">
                    <div class="item-notify" v-show="is_show_quan">
                        <p>
                            您有一张
                            <span class="special-txt">{{is_show_quan && quan_first.quan_title}}</span>
                            优惠券
                        </p>
                    </div>

                    <div class="bottom-price">
                        <div class="box-l item-price">
                            <p>
                                <span class="icon iconfont icon-fl-renminbi"></span>
                                <span class="num-txt">{{info.product_price}}</span>元
                            </p>
                        </div>
                    </div>

                    <div class="item-title">
                        <p>【{{info.category_title}}】{{info.product_title}}</p>
                    </div>
                </div>
                <div class="bottom-feature">
                    <div class="box-l">
                        <p>
                            <span class="icon iconfont icon-yanjing"></span>
                            <span class="view-txt">{{info.views}}人已看</span>
                        </p>
                    </div>
                    <div class="box-r">
                        <!-- <p class="like-txt">
                            <a href="javascript:;" @click="zan()">
                                <span class="icon iconfont icon-dianzan"></span>
                                <span class="num-txt">{{info.zan_count}}</span>
                            </a>
                        </p> -->

                        <p class="collect-txt">
                            <a href="javascript:;" @click="collect()">
                                <span class="icon iconfont icon-xingxing"></span>
                                <span class="num-txt">{{info.collect_count}}</span>
                            </a>
                        </p>
                    </div>
                </div>

                <!-- <div class="coupon-box">
                    <p class="title-01">
                        <span>领券</span>
                    </p>

                    <p class="title-02" v-for="item in quan_list" :key="item.quan_id">
                        <i class="dian-01"></i>
                        <span>{{item.quan_title}}</span>
                        <i class="dian-02"></i>
                    </p>

                    <p class="title-04">
                        <span>{{quan_count}}</span>
                        <span>个</span>
                        <i class="icon iconfont icon-right1"></i>
                    </p>
                </div> -->
            </div>
        </div>

        <div class="top-wrap">
            <p class="title-txt">
                <span class="title-01">项目详情</span>
            </p>
        </div>

        <div id="product_content" class="main-wrap" v-html="info.content"></div>

        <div class="func-foot">
            <ul class="func-frame">
                <li class="contact-box">
                    <a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzU3NDgzNDU4NQ==#wechat_redirect ">
                        <i class="icon iconfont icon-zixun1"></i>
                        <span>咨 询</span>
                    </a>
                </li>
                <!-- <li>
                    <button class="tel-btn">
                        <a href="tel:02258107619">电话预约</a>
                    </button>
                </li> -->
                <!-- <li>
                    <button class="buy-btn" @click="buy_submit">立即购买</button>
                </li> -->
            </ul>
        </div>
    </div>
</template>

<script type="text/ecmascript-6">
import searchPrdt from "./components/search";
import Banner from "@/components/banner";

import constant from "@/utils/constant.js";
// 引用API文件
import http from "@/utils/http.js";

import $ from "jquery";

export default {
  name: "detail",
  data() {
    return {
      info: {},
      quan_list: [],
      quan_count: 0,
      quan_first: {},
      is_show_quan: false,
        thumbs:[],
        constant:constant
    };
  },
  components: {
    searchPrdt,
    Banner
  },
  methods: {
    zan() {
      let id = this.$route.query.id;
      http.get(this, {
        url: "product/zan",
        data: {
          product_id: id,
          token: localStorage.getItem("user_token")
        },
        dataType: "json",
        success: function(data) {
          console.log("产品点赞:", data);
          if (data.status == 1) {
            this.info = data.info;
          }
        }
      });
    },
    collect() {
      let id = this.$route.query.id;
      http.get(this, {
        url: "product/collect",
        data: {
          product_id: id,
          token: localStorage.getItem("user_token")
        },
        dataType: "json",
        success: function(data) {
          console.log("产品收藏:", data);
          if (data.status == 1) {
            this.info = data.info;
          }
        }
      });
    },
    product_info() {
      let id = this.$route.query.id;
      http.get(this, {
        url: "product/detail",
        data: {
          id: id
        },
        dataType: "json",
        success: function(data) {
          console.log("产品详情:", data);
          if (data.status == 1) {
            this.info = data.info;
            this.thumbs = data.info.thumbs ? data.info.thumbs.split("|") :[]
          }
        }
      });
    },
    buy_submit() {
      let product_id = this.info.product_id;

      http.post(this, {
        url: "order/submit",
        data: {
          product_id: product_id,
          token: localStorage.getItem("user_token")
        },
        dataType: "json",
        success: function(data) {
          console.log("提交订单:", data);
          if (data.status == 1) {
            window.location.href = '/center/order';
          }
        }
      });
    },
    quan_info() {
      http.get(this, {
        url: "quan/quanorder_list",
        data: {
          token: localStorage.getItem("user_token"),
          pagesize: 2
        },
        dataType: "json",
        success: function(data) {
          console.log("我的优惠券:", data);
          if (data.status == 1) {
            this.quan_list = data.info.list;
            this.quan_count = data.info.total;

            if (this.quan_list != null && this.quan_list.length > 0) {
              this.quan_first = this.quan_list[0];
              this.is_show_quan = true;
            }
          }
        }
      });
    }
  },
  created() {
  },
  activated() {
    this.product_info();
    let user_token = localStorage.getItem("user_token");
    if(user_token){
      this.quan_info();
    }
  },
  updated() {
    let that = this;
    $("#product_content img").each(function(index, item) {
      let src = $(item).attr("src");
      if (!src.startsWith("http://") && !src.startsWith("https://")) {
        $(item).attr("src", that.constant.api_url + src);
      }
    });
  }
};
</script>
 <style lang="scss">
$letHeight: 0.76rem;

.prdt-select {
  height: 0.8rem;
  line-height: 0.8rem;

  .el-input__inner {
    line-height: 0.8rem;
    background-color: transparent;
    border: none;
    color: $c-mainC;
    font-size: 0.38rem;
    font-weight: 500;

    &::-webkit-input-placeholder {
      color: $c-mainC;
      font-weight: 500;
      font-size: 0.38rem;
    }
    &:-moz-placeholder {
      font-weight: 500;
      color: $c-mainC;
      font-size: 0.38rem;
    }
    &::-moz-placeholder {
      font-weight: 500;
      color: $c-mainC;
      font-size: 0.38rem;
    }
    &:-ms-input-placeholder {
      font-weight: 500;
      color: $c-mainC;
      font-size: 0.38rem;
    }
  }

  .el-input .el-select__caret {
    color: $c-mainC;
    font-size: 0.38rem;
    font-weight: 600;
    line-height: 0.8rem;
  }
}

.el-select-dropdown__list {
  li {
    text-align: center;
    font-weight: 500;
    color: $c-mainC;
  }
}

.nav-collapse {
  position: fixed;
  top: 0;
  left: 0;
  transform: translateX(-100%);
  width: 6rem;
  @extend .transit;
  min-height: 100vh;
  background-color: $c-white-light;
  z-index: $zindex-7;

  &.open {
    transform: translateX(0%);
  }

  .title-txt {
    padding: 0 0.36rem;
    $letHeight: 0.9rem;
    height: $letHeight;
    line-height: $letHeight;

    span {
      font-size: 0.38rem;
      color: $c-mainC;
      float: left;
    }

    i {
      color: $c-mainC;
      font-size: 0.8rem;
      float: right;
    }
  }
}

.el-menu {
  .el-submenu__title {
    font-size: 0.3rem;
    color: $c-themeC !important;
    span {
      color: inherit;
    }
  }

  .el-menu-item {
    font-size: 0.28rem;
  }

  .el-submenu {
    border-top: 0.15rem solid $c-gray-dark;
  }
}

.category-select {
  $letHeight: 0.7rem;
  width: 100%;
  margin: 0.22rem auto !important;
  @extend .cmm-border;

  .el-button {
    line-height: $letHeight;
    background-color: $c-themeBg;
    color: $c-white-light;
    font-size: 0.26rem;
    width: 2.36rem;
    border-right: 0.02rem solid $c-white-light;

    margin-right: 0 !important;
    &:last-child {
      border-right: none;
    }
    span {
      color: inherit;
    }
    i {
      color: inherit;
      margin-left: 0.28rem;
      font-size: 0.28rem;
    }
  }
}
</style>

 <style scoped lang="scss">
.top-wrap {
  $letHeight: 1.14rem;
  border-top: 0.15rem solid $c-gray-dark;
  border-bottom: 0.15rem solid $c-gray-dark;

  .title-txt {
    height: $letHeight;
    line-height: $letHeight;
    text-align: center;
    background-color: $c-white-light;

    span {
      color: $c-mainC;
      display: inline-block;
      line-height: $letHeight;
      vertical-align: middle;

      &.title-01 {
        font-size: 0.38rem;
      }
    }
  }
}

.main-wrap {
  width: 100%;
  padding: 0.4rem 0.2rem 0.4rem 0.2rem;
    font-size: 0.28rem;
    line-height: 0.48rem;

  img {
    width: 100%;
  }
}

.item-box {
  margin: 0;
  width: 100%;

  .img-wrap {
    width: 100%;
    height: 2.37rem;
    overflow: hidden;
    position: relative;
    border-radius: 0.1rem;

    .ad-img {
      @extend .cmm-translateXY;
    }
  }

  $letHeight: 0.52rem;

  .bottom-info {
      margin-top: 0.14rem;

    .box-l {
      width: 100%;
      float: none;
    }

    .box-r {
      width: 50%;
      float: right;
    }

    .item-notify {
      background-color: $c-gray-dark;

      p {
        width: 100%;
        font-size: 0.26rem;
        line-height: 0.56rem;
        text-align: left;
        padding-left: 0.14rem;

        .special-txt {
          color: $c-danger;
        }
      }
    }

    .item-title {
        padding: 0 0.2rem;
        margin:0.1rem 0;
      p {
        width: 100%;
        font-size: 0.26rem;
        line-height: 0.3rem;
        text-align: left;
      }
    }
  }

  .item-price {
    margin-top: 0.14rem;
    p {
      font-size: 0.32rem;
      color: $c-themeC;
      text-align: right;
      line-height: $letHeight;
      letter-spacing: -0.01rem;
    }

    span {
      display: inline-block;
      line-height: 0.52rem;
      float: left;
    }

    .icon {
      font-size: 0.4rem;
      margin-right: 0rem;
    }
  }

  .bottom-feature {
    @extend .cmm-clearfix;
    height: $letHeight;
    padding: 0 0.2rem;
    margin: 0rem auto;

    .box-l {
      width: 50%;
      float: left;

      p {
        color: $c-mainC;
        font-size: 0.22rem;
        white-space: nowrap;
        letter-spacing: -0.02rem;

        * {
          vertical-align: middle;
          display: inline-block;
        }

        span {
          line-height: 0.52rem;
        }
      }

      .icon {
        font-size: 0.28rem;
        color: $c-themeC;
        font-weight: bold;
      }
    }

    .box-r {
      width: 50%;
      text-align: right;
      float: right;

      p {
        display: inline-block;
        line-height: $letHeight;
        white-space: nowrap;
        letter-spacing: -0.02rem;

        * {
          vertical-align: middle;
          display: inline-block;
          letter-spacing: -0.02rem;
        }
      }

      .like-txt {
        width: 50%;
        float: left;
      }
      .collect-txt {
        width: 50%;
        float: left;
      }

      p {
        span {
          line-height: 0.52rem;
        }
      }

      .icon {
        line-height: 0.52rem;
        display: inline-block;
        font-size: 0.4rem;
        font-size: 0.28rem;
        color: $c-themeC;
        font-weight: bold;
      }

      .num-txt {
        color: $c-mainC;
        font-size: 0.22rem;
        line-height: 0.52rem;
      }
    }
  }

  .bottom-price {
    @extend .cmm-clearfix;
    width: 100%;
    padding: 0 0.14rem;
    margin: 0.1rem auto;
    .box-l {
      width: 50%;
      float: left;
    }

    .item-price {
      text-align: left;
      vertical-align: top;

      p {
        text-align: left;
      }

      * {
        vertical-align: top;
      }
    }
  }

  .coupon-box {
    $letHeight: 0.32rem;
    height: $letHeight;
    vertical-align: top;
    padding: 0 0.14rem;
    margin: 0.3rem auto;

    p {
      line-height: $letHeight;
      width: 100%;
      @extend .cmm-clearfix;
      vertical-align: top;
      box-sizing: border-box;
      padding: 0;
      display: inline-block;
      max-width: 2.6rem;
    }
    .title-01 {
      float: left;
      width: 0.6rem;
      text-align: center;
    }

    .title-02 {
      float: left;
      background-color: #ffbfbf;
      color: $c-danger;
      position: relative;
      text-align: center;
    }

    .title-03 {
      float: left;
      background-color: #ffbfbf;
      color: $c-danger;
      position: relative;
      text-align: center;
      margin-left: 0.2rem;
    }

    .title-04 {
      float: right;
      width: 1.2rem;
      text-align: right;
    }

    p {
      overflow: hidden;

      .dian-01 {
        line-height: $letHeight;
        display: inline-block;
        border-radius: 100%;
        background-color: $c-white-light;
        vertical-align: top;
        @extend .cmm-translateXY;
        left: 0;

        width: 0.2rem;
        height: 0.2rem;
      }
      .dian-02 {
        line-height: $letHeight;
        display: inline-block;
        background-color: $c-white-light;
        border-radius: 100%;
        vertical-align: top;
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateX(50%) translateY(-50%);
        width: 0.2rem;
        height: 0.2rem;
      }

      .icon {
        color: $c-mainC;
        font-weight: bold;
        font-size: 0.3rem;
        margin-left: 0.1rem;
      }
    }

    span {
      display: inline-block;
      line-height: $letHeight;
      color: $c-mainC;
      vertical-align: top;
      margin-right: 0.02rem;
    }
  }
}

$letHeight: 1.24rem;
.func-foot {
  height: $letHeight;
  position: relative;
  position: fixed;
  bottom: 0;
  z-index: $zindex-5;
  width: 100%;
}

.func-frame {
  width: 100%;
  height: $letHeight;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-content: center;

  li {
    height: $letHeight;

    &.contact-box {
    //   width: 1.22rem;
      width: 100%;
      height: $letHeight;
      background-color: $c-white-light;

      a {
        display: flex;
        flex-wrap: wrap;
        flex-direction: column;
        justify-content: center;
        align-content: center;
        width: 100%;
        height: 100%;
        color: $c-mainC;
        text-align: center;
        font-size: 0.24rem;
        padding: 0.1rem 0;
        background-color: $c-white-light;

        i {
          font-size: 0.5rem;
          display: block;
          margin: 0 auto 0;
          flex-grow: 0;
          height: 0.6rem;
          color: $c-themeC;
        }
      }
    }

    .tel-btn {
      line-height: $letHeight;
      background-color: $c-themeBg;
      color: $c-white-light;
      text-align: center;
      width: 6.3rem;
      width: 100%;
      font-size: 0.38rem;
    }

    .buy-btn {
      line-height: $letHeight;
      background-color: #c4aa6e;
      color: $c-white-light;
      text-align: center;
      width: 3.15rem;
      font-size: 0.38rem;
    }
  }
}
</style>
